home *** CD-ROM | disk | FTP | other *** search
- Path: news.netins.net!trg1
- From: hhowe@trgnet.com (Harold Howe)
- Newsgroups: comp.lang.c++
- Subject: Object constuction in function call.
- Date: Fri, 15 Mar 96 20:21:33 GMT
- Organization: Technology Resource Group
- Message-ID: <4icmqh$8g6@insosf1.netins.net>
- NNTP-Posting-Host: desm-21-00.dialup.netins.net
- X-Newsreader: News Xpress Version 1.0 Beta #3
-
- Greetings.
-
- I need help. If an object is contructed in a function call, how long does it
- exist. For example, (this is not what I am doing, but it illustrates the
- point).
-
- class TCorners
- {
- public:
- int w,x,y,z;
- TCorners( int a, int b, int c, int d)
- { w=a; x=b; y=c; z=d;}
- }
-
- void display_coordinates(TCorners corners)
- {
- cout << "corners are" << corners.w << corners.x
- << corners.y << corners.z ;
- }
-
- int main(void)
- {
- display_coordinates(TCorners(1,1,20,10));
- display_coordinates(TCorners(1,5,25,15));
- display_coordinates(TCorners(2,5,20,10));
- }
-
- How many objects exist at the programs end? Are the objects created for the
- function call, then nuked afterwards? I think they hang around, in fact I
- know they hang around because if I call the display guy about 100 times the
- program finally blows up. I would like to use this syntax if possible in the
- real program that I am writing.
-
- Any suggestions would be appreciated.
- Harold Howe
- hhowe@trgnet.com
-
-